<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>查看-配偶、父母或其他信息</title>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css" />
    <script src="/static/js/common/common.js" type="text/javascript"></script>
    <link href="/webjars/miniui/css/demo.css" rel="stylesheet" type="text/css" />
    <link href="/static/css/default.css" rel="stylesheet" type="text/css" />
    <style>
        .discell {
            text-align:right;
            width:100px;
        }
        .input {
            width:100px;
        }
    </style>
</head>
<body>
<div class="mini-fit" style="margin-bottom: 40px">
    <div style="height:100%;width: 100%;overflow-x: auto;overflow-y: auto;">
        <form id="form1" method="post">
            <input name="id" id="id" class="mini-hidden" style="width: 100%" readonly />
            <input name="priNum" id="priNum" class="mini-hidden" style="width: 100%" readonly />
            <br>
            <table align="center" cellspacing="8" style="border-collapse:separate; border-spacing:10px;">

                <tr>
                    <td class="discell"><font color="#dc143c">*</font>姓&emsp;&emsp;名:</td>
                    <td class="input">
                        <input name="thename" id="thename" class="mini-textbox" required="true" emptyText="请输入姓名" readonly="readonly"
                               style="width: 230px" /><font style="color: red;display: none" id="thename1">被编辑</font>
                    </td>
                    <td class="discell">关&emsp;&emsp;系:</td>
                    <td class="input">
                        <input name="relation" id="relation" class="mini-combobox" required="true"
                               textField="codeName" valueField="codeId" emptyText="请选择..." style="width: 230px;"
                               url="/azbj/inmates/baseinfo/getTbsysCode?codeType=2_6&pcodeId=99&sn=1" readonly="readonly"
                        /><font style="color: red;display: none" id="relation1">被编辑</font>
                    </td>
                </tr>
                <tr>
                    <td class="discell">证件类型:</td>
                    <td class="input">
                        <input name="idType" id="idType" class="mini-combobox"
                               textField="codeName" valueField="codeId" emptyText="请选择..." style="width: 230px;"
                               url="/azbj/inmates/baseinfo/getTbsysCode?codeType=2_13&pcodeId=-1&sn=1"
                        /><font style="color: red;display: none" id="idType1">被编辑</font>
                    </td>
                    <td class="discell">身份证号:</td>
                    <td>
                        <input name="idnumber" id="idnumber" class="mini-textbox" emptyText="请输入身份证号" style="width: 230px" readonly /><font style="color: red;display: none" id="idnumber1">被编辑</font>
                    </td>
                </tr>
                <tr>
                    <td class="discell">性&emsp;&emsp;别:</td>
                    <td class="input">
                        <input name="gender" id="gender" class="mini-combobox"
                               textField="codeName" valueField="codeId" emptyText="请选择..." style="width: 230px;"
                               url="/azbj/inmates/baseinfo/getTbsysCode?codeType=66&pcodeId=-1&sn=1"
                        /><font style="color: red;display: none" id="gender1">被编辑</font>
                    </td>
                    <td class="discell">出生日期:</td>
                    <td class="input">
                        <input property="editor" class="mini-datepicker" id="age" name="age" allowInput="true" emptyText="请选择出生日期"
                               style="width: 230px" readonly /><font style="color: red;display: none" id="age1">被编辑</font>
                    </td>
                </tr>
                <tr>
                    <td class="discell">工作单位:</td>
                    <td colspan="3">
                        <input name="danwei" id="danwei" class="mini-textbox" required="true" emptyText="请输入工作单位" style="width: 96%" readonly /><font style="color: red;display: none" id="danwei1">被编辑</font>
                    </td>
                </tr>
                <tr>
                    <td class="discell">手机号码:</td>
                    <td class="input">
                        <input name="tel" id="tel" class="mini-textbox" required="true" emptyText="请输入手机号码" readonly="readonly"
                               style="width: 230px" /><font style="color: red;display: none" id="phone1">被编辑</font>
                    </td>
                    <td class="discell">固话:</td>
                    <td class="input">
                        <input name="fixedLine" id="fixedLine" class="mini-textbox" required="true" emptyText="请输入固定电话" readonly="readonly"
                               style="width: 230px" /><font style="color: red;display: none" id="tel1">被编辑</font>
                    </td>
                </tr>
                <tr>
                    <td class="discell">家庭住址:</td>
                    <td colspan="3" style="width: 800px;">
                        <input id="addrpro" name="addrpro" class="mini-combobox" required="true" emptyText="省份" style="width: 190px"
                               textfield="codeName" valueField="codeId" readonly="readonly"/>
                        <input id="addrcity" name="addrcity" class="mini-combobox" required="true" emptyText="市" style="width: 190px"
                               textfield="codeName" valueField="codeId" readonly="readonly"/>
                        <input id="addrcou" name="addrcou" class="mini-combobox" required="true" emptyText="县" style="width: 190px"
                               textfield="codeName" valueField="codeId" readonly="readonly"/>
                        <input id="addrvil" name="addrvil" class="mini-combobox" emptyText="街道" style="width: 180px" readonly="readonly"
                               textfield="codeName" valueField="codeId"/><font style="color: red;display: none" id="addrpro1">被编辑</font>
                    </td>
                </tr>
                <tr>
                    <td class="discell"></td>
                    <td colspan="3" style="width: 500px;">
                        <input class="mini-textbox" required="true" style="width: 760px" emptyText="详细地址" id="addrdetail" name="addrdetail"
                               readonly="readonly" /><font style="color: red;display: none" id="addrdetail1">被编辑</font>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>

<div style="position: absolute;bottom:0;line-height: 40px;width: 100%;border-top: 1px solid #dfdfdf;text-align: center">
    <a class="mini-button" iconCls="fa-close" plain="true" style="font-size: 15px" onclick="onCancel()">关闭</a>
</div>

<script type="text/javascript">

    mini.parse();
    var form = new mini.Form("form1");
    var id = mini.get("id");
    var tel = mini.get("tel");
    var priNum = mini.get("priNum");
    var addrpro = mini.get("addrpro");
    var addrcity = mini.get("addrcity");
    var addrcou = mini.get("addrcou");
    var addrvil = mini.get("addrvil");
    form.setEnabled(false);

    function SetData(data) {
        //设置表格为不可编辑类型
        form.setEnabled(false);
        if (data.id) {
            mini.get("id").setEnabled(false);
        }
        $.ajax({
            url: "/azbj/social/srinfo?id=" + data.id,
            type: "post",
            dataType: "json",
            success: function (srdata) {
                var telAndPhone = getTelAndPhone(srdata);
                srdata.tel = telAndPhone['phone'];
                srdata.fixedLine = telAndPhone['tel'];
                var zd = mini.decode(srdata);
                form.setData(srdata);
                form.setChanged(false);
                addrpro.setData([{codeId: srdata.addrpro, codeName: srdata.addrproname}]);
                addrcity.setData([{codeId: srdata.addrcity, codeName: srdata.addrcityname}]);
                addrcou.setData([{codeId: srdata.addrcou, codeName: srdata.addrcouname}]);
                addrvil.setData([{codeId: srdata.addrvil, codeName: srdata.addrvilname}]);
            }
        });
    }

    function getTelAndPhone(o) {
        var telAndPhone = o.tel;
        if (telAndPhone.includes("|")) {
            var tel = telAndPhone.substring(0, telAndPhone.indexOf("|"));
            var phone = telAndPhone.substring(telAndPhone.indexOf("|") + 1, telAndPhone.length);
        } else {
            if ((/^1[3456789]\d{9}$/.test(telAndPhone))) {
                var tel = "";
                var phone = telAndPhone;
            } else {
                var tel = telAndPhone;
                var phone = "";
            }
        }
        var telAndPhoneBack = {'tel': tel, 'phone': phone};
        return telAndPhoneBack;
    }

    window.onload = function () {
        priNum.setValue(${priNum});
        var localCode = '${localCode !''}';
        if(localCode == '140000') {
            var addrpro = '${addrpro !''}';
            var addrcity = '${addrcity !''}';
            var addrcou = '${addrcou !''}';
            var addrvil = '${addrvil !''}';
            var addrdetail = '${addrdetail !''}'
            var danwei = '${danwei!''}'
            var age = '${age!''}'
            var idnumber = '${idnumber!''}'
            var thename = '${thename!''}'
            var relation = '${relation!''}'
            var tel = '${tel!''}'
            var phone = '${phone!''}'
            var idType = '${idType!''}'
            var gender = '${gender!''}'
            if (gender == "true") {
                document.getElementById("gender1").style.display = "inline-block";
            }
            if (idType == "true") {
                document.getElementById("idType1").style.display = "inline-block";
            }
            if (addrpro == "true" || addrcity == "true" || addrcou == "true" || addrvil == "true") {
                document.getElementById("addrpro1").style.display = "inline-block";
            }
            if (addrdetail == "true") {
                document.getElementById("addrdetail1").style.display = "inline-block";
            }
            if (danwei == "true") {
                document.getElementById("danwei1").style.display = "inline-block";
            }
            if (age == "true") {
                document.getElementById("age1").style.display = "inline-block";
            }
            if (idnumber == "true") {
                document.getElementById("idnumber1").style.display = "inline-block";
            }
            if (thename == "true") {
                document.getElementById("thename1").style.display = "inline-block";
            }
            if (relation == "true") {
                document.getElementById("relation1").style.display = "inline-block";
            }
            if (tel == "true") {
                document.getElementById("tel1").style.display = "inline-block";
            }
            if (phone == "true") {
                document.getElementById("phone1").style.display = "inline-block";
            }
        }
    }
</script>
</body>
</html>